home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17917 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.lang.c++,comp.lang.c++.moderated
  4. Subject: Re: Dynamic class definitions in C++: possible?
  5. Date: 17 Apr 1996 15:13:49 -0000
  6. Organization: GABI Software, Sarl.
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4l31rd$7bj@netlab.cs.rpi.edu>
  10. References: <4ko91f$1cb@netlab.cs.rpi.edu> <4koodt$2hh@netlab.cs.rpi.edu>
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: 17 Apr 1996 14:42:11 GMT
  13.  
  14. In article <4koodt$2hh@netlab.cs.rpi.edu> javaprog@best.com (John
  15. Lockwood) writes:
  16.  
  17. |> Kyle.F.Downey@williams.edu (Kyle F. Downey) wrote:
  18.  
  19. |> >1) load a C++ class definition from a file
  20. |> >2) convert it to an internal format
  21. |> >3) use the class just as you would a compiled class
  22.  
  23. |> >This would allow you to add a class at run-time based on a
  24. |> >text/user-supplied definition. 
  25.  
  26. |> Why not rethink the problem?
  27.  
  28. |> 1) Read some data from a file.
  29. |> 2) Do something with this data using the rich language features that
  30. |> C++ offers (polymorphism, templates, etc).
  31. |> 3) Make your program work just as if you'd implemented it using 
  32. |> some wierd JAVA-inspired idea.
  33.  
  34. |> I'm not trying to be intentionally dense here.  If there are problems
  35. |> that can only be solved in the way you've outlined and not in the way
  36. |> I have, I'd be interested if you or others would chime in.
  37.  
  38. There is one frequent use for this sort of thing: upgrading the software
  39. of an installation without stopping it.  For example, if you want a
  40. telephone switch to handle a new type of terminal, you write the code
  41. for the new class (which derives from the class `Terminal' already known
  42. to the system), then add it to a running system.
  43.  
  44. Coplien discusses several (very) non-portable solutions to do this.
  45. Under most systems, however, I would see if something along the lines of
  46. implemening a command to load a DLL in the original software wouldn't
  47. work.  If this is possible, then all you should have to do to add a new
  48. type is to link the code as a DLL, then load it.  (I am also supposing
  49. here that any static variables in the DLL will be constructed when the
  50. DLL is loaded.  One static variable would contain all of the pertinate
  51. information concerning the new terminal type, and would register itself
  52. with the existing software in its constructor.)
  53. -- 
  54. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  55. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  56. Conseils en informatique industrielle --
  57.                             -- Beratung in industrieller Datenverarbeitung
  58.  
  59.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  60.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  61.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  62.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  63.